/** @jsxImportSource @emotion/react */
import * as React from "react";
import { ReportViewProps, } from "../../common/base";
import {末尾链接, } from "../../common/rarelyVary";
import {CCell, Cell, Embed, RCell, Table, TableBody, TableRow, Text, useTheme} from "customize-easy-ui-component";
import {ReportFirstPageHeadCyMa} from "../../valve/rarelyVary";
import {FadeImage} from "../../../comp/FadeImage";
import Img_TS from "../../../images/TS.png";
import {config证书概要} from "./Regular.O-1";
import {TwoRaftDeviceInfo} from "../../contain/views";

export const ReportView: React.FunctionComponent<ReportViewProps> = ({
    repId,   source: orc,  verId,rep,
}) => {
  return (
    <React.Fragment>
        <div css={{"@media not print": {marginTop: '1rem', marginBottom: '1rem'}}}>
          <CertificatePage orc={orc} rep={rep}/>
        </div>
        {末尾链接({template: rep?.modeltype, verId, repId: repId || ''})}
    </React.Fragment>
  );
}
export const CertificatePage= ({ orc, rep, children} : { orc: any,rep: any,children?: React.ReactNode}
) => {
    const theme= useTheme();
    const callback = () => {
        return <div  css={{"@media print": {height:'100vh', overflowY: 'hidden',} }}>
            { ReportFirstPageHeadCyMa({theme,rep, mbbm:'FJB/RA-1022-0-2016',nMa:true}) }
            <div css={{
                "@media print": {
                    display: 'flex',
                    flexDirection: 'column',
                    justifyContent: 'space-around',
                    height: 'calc(100vh - 4rem)',
                }
            }}>
                <Text variant="h3" css={{textAlign:'center',lineHeight:'0.8', "@media print": {fontSize: theme.fontSizes[5],},}}>
                    特种设备制造监督检验证书<br/>
                    <Text>（压力容器）</Text>
                </Text>
                <div>
                    <div css={{display: 'flex',justifyContent: 'space-between',}}>
                        &nbsp;
                        <Text css={{display: 'flex',flexDirection: 'row-reverse',marginRight: '2rem'
                        }}>监检编号：{rep.isp?.no}</Text>
                    </div>
                    <Table fixed={ ["14.1%", "38%", "14.1%", "%"] }  css={ {borderCollapse: 'collapse',
                                        "@media print": {height:'72vh',} } } tight  miniw={800}>
                        <TableBody>
                            <TwoRaftDeviceInfo orc={orc} rep={rep} config={config证书概要}/>
                            <TableRow>
                                <CCell colSpan={4}>
                                    <Table  fixed={ ["24%", "39%", "6.6%", "%"] }
                                            css={ {borderCollapse: 'collapse', "@media print": {height:'fill-available'},} }  tight  miniw={800}>
                                        <TableBody>
                                            <TableRow>
                                                <Cell css={{border:'none',textIndent:'2rem'}} colSpan={4}>按照《中华人民共和国特种设备安全法》《特种设备安全监察条例》的规定，
                                                    该台压力容器产品经我机构实施监督检验，安全性能符合《固定式压力容器安全技术监察规程》（TSG 21-2016）的要求，特发此证书，
                                                    并且在该台压力容器产品铭牌上打有如下监检标志。</Cell>
                                            </TableRow>
                                            <TableRow>
                                                <Cell css={{border:'none'}} colSpan={4}>
                                                    <Embed css={{width: "96px",margin: "auto",top: '-0.15rem'}} width={43} height={43}>
                                                        <FadeImage src={Img_TS}/>
                                                    </Embed>
                                                </Cell>
                                            </TableRow>
                                            <TableRow css={{"@media print": {height:'3rem'} }}>
                                                <RCell css={{border:'none'}}>监检员：</RCell>
                                                <Cell css={{border:'none'}}>机erter</Cell>
                                                <RCell css={{border:'none'}}>日期：</RCell>
                                                <Cell css={{border:'none'}}></Cell>
                                            </TableRow>
                                            <TableRow css={{"@media print": {height:'3rem'} }}>
                                                <RCell css={{border:'none'}}>审   核：</RCell>
                                                <Cell css={{border:'none'}}></Cell>
                                                <RCell css={{border:'none'}}>日期：</RCell>
                                                <Cell css={{border:'none'}}>2024-04-10</Cell>
                                            </TableRow>
                                            <TableRow css={{"@media print": {height:'3rem'} }}>
                                                <RCell css={{border:'none'}}>批   准：</RCell>
                                                <Cell css={{border:'none'}}></Cell>
                                                <RCell css={{border:'none'}}>日期：</RCell>
                                                <Cell css={{border:'none'}}>2024-04-10</Cell>
                                            </TableRow>
                                            <TableRow>
                                                <RCell css={{border:'none'}}>监督检验机构：</RCell>
                                                <Cell colSpan={2} css={{border:'none'}}>{rep?.isp?.ispu?.name}</Cell>
                                                <CCell css={{border:'none'}}>（监督检验机构检验专用章）</CCell>
                                            </TableRow>
                                            <TableRow css={{"@media print": {height:'fill-available'} }}>
                                                <RCell  css={{border:'none'}}>监督检验机构核准证号：</RCell>
                                                <Cell  colSpan={2} css={{border:'none'}}>{rep?.isp?.ispu?.agency?.apno}</Cell>
                                                <CCell css={{border:'none'}}>2024-04-10</CCell>
                                            </TableRow>
                                        </TableBody>
                                    </Table>
                                </CCell>
                            </TableRow>
                        </TableBody>
                    </Table>
                </div>
                <Text css={{fontSize:'0.8rem'}}>注：本证书一式三份，一份监督检验机构存档，两份送制造单位，其中一份由制造单位随产品出厂资料交付使用单位。
                </Text>
            </div>
        </div>
    }
    return <>
        <div id="Certificate"/>
        {callback()}
    </>;
};
